using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace UserControls
{
    public partial class TienIchControls : UserControl
    {
        public TienIchControls()
        {
            InitializeComponent();
        }

        public delegate void bttClick(object sender, EventArgs e);

        public bttClick btt_click1 = null;
        public bttClick btt_click3 = null;

        //
        // Ham va thuoc tinh
        //
        public bool CheckTieuDeBangHH
        {
            get { return xCheckBox1.Checked; }
            set { xCheckBox1.Checked = value; }
        }
        public bool CheckDieuKienThanhMN
        {
            get { return xCheckBox2.Checked; }
            set { xCheckBox2.Checked = value; }
        }
        public bool CheckTatThoiGianHH
        {
            get { return xCheckBox3.Checked; }
            set { xCheckBox3.Checked = value; }
        }
        public bool CheckTatCheDoTuDongHT
        {
            get { return xCheckBox4.Checked; }
            set { xCheckBox4.Checked = value; }
        }
        public bool CheckTatHinhNenThanhMN
        {
            get { return xCheckBox5.Checked; }
            set { xCheckBox5.Checked = value; }
        }
        public bool EnableGroupDangNhap
        {
            get { return xGroup5.Enabled; }
            set
            {
                xGroup5.Enabled = value;
            }
        }
        public bool EnableGroupHieuChinh
        {
            get { return xGroup7.Enabled; }
            set
            {
                xGroup7.Enabled = value;
            }
        }


        public string TxtUser
        {
            get { return xTextBox1.Text; }
            set
            {
                if (value == null)
                {
                    value = "";
                }
                xTextBox1.Text = value;
            }
        }
        public string TxtPass
        {
            get { return xTextBox2.Text; }
            set
            {
                if (value == null)
                {
                    value = "";
                }
                xTextBox2.Text = value;
            }
        }
        public string TxtUserHC
        {
            get { return xTextBox6.Text; }
            set
            {
                if (value == null)
                {
                    value = "";
                }
                xTextBox6.Text = value;
            }
        }
        public string TxtPassHC
        {
            get { return xTextBox7.Text; }
            set
            {
                if (value == null)
                {
                    value = "";
                }
                xTextBox7.Text = value;
            }
        }

        public void OpenThanhTieuDe(bool open)
        {
            if (open)
                xGroup1.Expand();
            else
                xGroup1.Collapse();
        }
        public void OpenDieuThanhMenu(bool open)
        {
            if (open)
                xGroup2.Expand();
            else
                xGroup2.Collapse();
        }
        public void OpenDieuMayTinh(bool open)
        {
            if (open)
                xGroup3.Expand();
            else
                xGroup3.Collapse();
        }
        public void OpenDieuLichBieu(bool open)
        {
            if (open)
                xGroup4.Expand();
            else
                xGroup4.Collapse();
        }
        public void OpenDanhNhap(bool open)
        {
            if (open)
                xGroup5.Expand();
            else
                xGroup5.Collapse();
        }
        public void OpenHieuChinh(bool open)
        {
            if (open)
                xGroup7.Expand();
            else
                xGroup7.Collapse();
        }

        public void Open(bool open)
        {
            if (!open)
            {
                xTabControl1.Width = 0;
                this.Width = 11;
            }
            else
            {
                xTabControl1.Width = 270;
                this.Width = 281;
            }
        }
        public void ChangeTab(int tabIndex)
        {
            if (tabIndex >= 0 && tabIndex < xTabControl1.TabCount)
                xTabControl1.SelectedIndex = tabIndex;
            else
                throw new ExcUser("tabIndex nam ngoai gioi han (ChangeTab)");
        }

        //
        // Dieu Khien Su Kien
        //
        private void xButtonEx1_Click(object sender, EventArgs e)
        {
            if(btt_click1!=null)
                btt_click1(sender, e);
        }
        private void xButtonEx3_Click(object sender, EventArgs e)
        {
            if (btt_click3 != null)
                btt_click3(sender, e);
        }   
        private void xPictureButton1_MouseDown(object sender, MouseEventArgs e)
        {
            if (this.Width == 281)          
                this.Width = 11;
            else
                this.Width = 281;
        }
        private void TienIchControls_Load(object sender, EventArgs e)
        {
            xGroup2.Collapse();
            xGroup4.Collapse();
            xGroup7.Collapse();
            xTabControl1.SelectedIndex = 1;
            Open(true);
        }

        private void xTreeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {

        }

        private void xTextBox1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
                xButtonEx1_Click(sender, e);
        }

        private void xTextBox2_KeyDown(object sender, KeyEventArgs e)
        {
            if(e.KeyCode==Keys.Enter)
                xButtonEx1_Click(sender, e);
        } 
    }
}
